        <?php        
session_start();      
include_once 'data_access.php';
$connect=new database_access();
$connect->connect();
   include 'admin.php';
$admin=new admin();
$result=$admin->selectrooms();
while($row=mysql_fetch_array($result)){
  $result2=$admin->selectstudentinroom($row['room_id'],$row['building_id']);
  $num_ros=mysql_num_rows($result2);
  echo $num_ros;
  if($num_ros==$row['room_capacity']){
      continue;
  }
  else{
      $result3=$admin->studentnotinroom($row['building_id']);
      while($num_ros != $row['room_capacity']){
        $r=mysql_fetch_array($result3);
        $admin->updatestudentroom($row['room_id'], $r['student_personalnumber']);
      $num_ros++;
      }
  }
}
header('location: studentdestributedinroom.php');
        ?>